package homework.day03;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * @Classname: HomeWork02
 * @Author: bromide
 * @CreateTime: 2022/4/2--13:16
 * @Version: V1.0
 * @Description: 程序实现的是简易记事本工具。程序启动后向pw.txt文件写内容
 * 用户输入的每一行字符串都写入到文件中，单独输入exit时
 * 程序退出。
 */
public class HomeWork02 {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner scanner = new Scanner(System.in);

        File file = new File("pw.txt");
        FileOutputStream fos = new FileOutputStream(file, true);
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw = new BufferedWriter(osw);
        PrintWriter pw = new PrintWriter(bw, true);

        String line;
        while (!"exit".equalsIgnoreCase(line = scanner.nextLine())) {
            pw.println(line);
        }
        pw.close();
    }
}
